package com.king.single;

/**
 * 饿汉式单例
 * 一开始就创建对象
 */
public class HungrySingleton {

    //这些属性可能会浪费内存
    private byte[] bytes1 = new byte[1024*1024];
    private byte[] bytes2 = new byte[1024*1024];
    private byte[] bytes3 = new byte[1024*1024];
    private byte[] bytes4 = new byte[1024*1024];

    private HungrySingleton(){}

    private final static HungrySingleton HUNGRY_SINGLETON = new HungrySingleton();

    public static HungrySingleton getInstance(){
        return HUNGRY_SINGLETON;
    }
}
